const path = require('path');
const webpack = require('webpack');

module.exports = {
    entry: {
        idx: './src/idx.js',
        idx2: './src/idx2.js',
        // 三方库
        vendor: ['lodash']
    },
    output: {
        filename: '[name].[chunkHash].js',
        path: path.resolve(__dirname, './dist/'),
        chunkFilename: '[name].chunk.js'        
    },
    plugins: [

        // 拆离开第三方库
        new webpack.optimize.CommonsChunkPlugin({
             name: "vendor",
             minChunks: Infinity // 希望打包出来的只要它自己没有别的
        }),

        new webpack.optimize.CommonsChunkPlugin({
            name: "common", 
            minChunks: 2
        }),
    ]
}
